package org.xcorpio.java8.chapter05;

import java.util.OptionalInt;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import org.xcorpio.java8.common.Data;
import org.xcorpio.java8.common.Dish;

public class NumericStreams {

    public static void main(String[] args) {
        int calories = Data.Menu.stream()
                 .mapToInt(Dish::getCalories)
                 .sum();
        System.out.println(calories);
        IntStream intStream = Data.Menu.stream().mapToInt(Dish::getCalories);
        System.out.println(intStream);
        Stream<Integer> boxed = intStream.boxed();
        System.out.println(boxed);
        OptionalInt optionalInt = Data.Menu.stream().mapToInt(Dish::getCalories).max();
        System.out.println(optionalInt.orElse(1));
        IntStream.range(1, 10).forEach(System.out::println);
        IntStream.rangeClosed(1, 10).forEach(System.out::println);
    }
}
